import time

def bubble_sort(nums):
    swapped = True
    while swapped:
        swapped = False
        for i in range(len(nums) - 1):
            if nums[i] > nums[i + 1]:
                nums[i], nums[i + 1] = nums[i + 1], nums[i]
                swapped = True

def read2list(filename):
    file = open(filename, 'r')
    data = file.readlines()
    data = [int(element.strip()) for element in data] # Convert elements to integers
    return data

plu1 = read2list("plu1_sorted.txt")
plu2 = read2list("plu2_reverse.txt")
plu3 = read2list("plu3_shuffle.txt")

t_start = time.time()
bubble_sort(plu1)
t_finish = time.time()
print("plu1_sorted:", round((t_finish-t_start)*1000), "milliseconds")

t_start = time.time()
bubble_sort(plu2)
t_finish = time.time()
print("plu2_reverse:", round((t_finish-t_start)*1000), "milliseconds")

t_start = time.time()
bubble_sort(plu3)
t_finish = time.time()
print("plu3_shuffle:", round((t_finish-t_start)*1000), "milliseconds")